package Task2;

import java.util.ArrayList;

public class test {
    public static void main(String[] args) {
        lihua l =new lihua("小花",1);
        bosi b =new bosi("小波",2);
        taidi t = new taidi("小泰",3);
        hashiqi h =new hashiqi("二哈",2);
        ArrayList<lihua> list1=new ArrayList<>();
        list1.add(l);
        ArrayList<bosi> list2=new ArrayList<>();
        list2.add(b);
        ArrayList<taidi> list3=new ArrayList<>();
        list3.add(t);
        ArrayList<hashiqi> list4=new ArrayList<>();
        list4.add(h);
        keepPet(list1);
        keepPet(list2);
        keepPet2(list3);
        keepPet2(list4);
        keepPet3(list1);
        keepPet3(list2);
        keepPet3(list3);
        keepPet3(list4);



    }
    //养猫不养狗
    public static void keepPet(ArrayList<? extends cat> list){
        for (cat cat : list) {
            cat.eat();
        }
    }
    //养狗不养猫
    public static void keepPet2(ArrayList<? extends dog> list){
        for (dog d : list) {
            d.eat();
        }
    }
    //养狗又养猫
    public static void keepPet3(ArrayList<? extends Animal> list){
        for (Animal a : list) {

            a.eat();
        }
    }
}
